<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        *{
            margin: 0;
            padding: 0;
        }
        body{
            box-sizing: border-box;
        }
        div{
            width: 815px;
            margin: 0 auto;
        }
        img{
            width: 200px;
            height: 200px;
            opacity: 0.5;
        }
    </style>
</head>
<body>
    <div>
        <img src="imgs/3.jpeg" alt="">
        <img src="imgs/3.jpeg" alt="">
        <img src="imgs/3.jpeg" alt="">
        <img src="imgs/3.jpeg" alt="">
        <img src="imgs/3.jpeg" alt="">
        <img src="imgs/3.jpeg" alt="">
        <img src="imgs/3.jpeg" alt="">
        <img src="imgs/3.jpeg" alt="">
    </div>
    <script>
          var lis = document.querySelectorAll('img');
        for(var i = 0;i < lis.length;i++){
            lis[i].onmouseenter = function(){
                this.style.opacity = "1";
            }
            lis[i].onmouseleave = function(){
                this.style.opacity = "0.5";
            }
        }
    </script>
</body>
</html>